/**
 * Copyright (C) 2022-2023
 * All rights reserved, Designed By www.tonetn.com
 * 注意：
 * 本软件为www.tonetn.com开发研制，未经购买不得使用
 * 购买后可获得全部源代码（禁止转卖、分享、上传到码云、github等开源平台）
 * 一经发现盗用、分享等行为，将追究法律责任，后果自负
 */
package com.xunyin.modules.recharge.service.mapper;

import com.xunyin.common.mapper.CoreMapper;
import com.xunyin.modules.recharge.domain.TRechargeSet;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @Author xunyinyunshang  <3594419785@qq.com>
 * @date 2022-10-12
 */
@Repository
public interface TRechargeSetMapper extends CoreMapper<TRechargeSet> {

    @Select("select rs.* from t_recharge_set rs " +
            "  where rs.tea_house_id = #{teaHouseId} " +
            "  and rs.main_id = #{mainId} " +
            "  and rs.enable = 1 and rs.status = 1" +
            "  and not exists(select 1 from t_recharge_order ro where ro.order_status = 1 and ro.recharge_set_id = rs.id and ro.phone = #{userPhone} and rs.purchase_limits_one_flag=1)")
    List<TRechargeSet> selectByTeaHouseIdAndPhone(@Param("teaHouseId") Integer teaHouseId, @Param("userPhone") String userPhone, @Param("mainId") Integer mainId);

    //List<TRechargeSet> selectList(com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper<com.xunyin.modules.recharge.domain.TRechargeSet> );
}
